<?php
namespace App\Controller\Admin;

use App\Query\UserOutQuery;
use App\Repository\UserOutRepository;

class UserOutController extends Controller
{
    // 列表
    public function index()
    {
        $model = UserOutQuery::query(
            UserOutQuery::model(),
            $this->inputs('status', 'user_id', 'time')
        );
        
        // 返回全部
        if($this->input('all'))
        {
            return $model->get();
        }
        
        return $model->paginate(15)->toArray();
    }
    
    // 通过
    public function ok($id)
    {
        if($model = UserOutRepository::find($id))
        {
            if($model->setStatusOk())
            {
                $this->message('ok');
            }
        }
        
        $this->error('error');
    }
    
    // 拒绝
    public function no($id)
    {
        if($model = UserOutRepository::find($id))
        {
            if($model->setStatusNo())
            {
                $this->message('ok');
            }
        }
        
        $this->error('error');
    }
}